const starContainer = document.getElementById('starPattern');
let starsHtml = '';
const maxRows = 5; // 上下各5行

// 上半部分蓝色正三角形
for (let i = 1; i <= maxRows; i++) {
    const spaces = ' '.repeat((2 * maxRows - 1 - (2 * i - 1)) / 2);
    const stars = '*'.repeat(2 * i - 1);
    starsHtml += `<div style="color: blue;">${spaces}${stars}</div>`;
}

// 下半部分红色正三角形
for (let i = maxRows; i >= 1; i--) {
    const spaces = ' '.repeat((2 * maxRows - 1 - (2 * i - 1)) / 2);
    const stars = '*'.repeat(2 * i - 1);
    starsHtml += `<div style="color: red;">${spaces}${stars}</div>`;
}

starContainer.innerHTML = starsHtml;